Estoy tratando de agregar un elemento de lista a mi lista Ordenada capturando el elemento de lista en javaScript usando 'getElementByTagName' pero está dando un error:
list.appendChild is not a function
{ let btn = document.getElementById("btn"); let list = document.getElementsByTagName("ol"); btn.onclick = function(){ let node = document.createElement("li").appendChild(document.createTextNode("new item")); list.appendChild(node); } } <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>My Website</title> <script defer src = "js/index.js"></script> <link rel="stylesheet" href="css/style.css"> </head> <body> <ol id="items"> <li class="border">Home</li> <li>Contact</li> <li class="border" id="special">About us</li> </ol> <button id="btn"> Click me</button><br> </body> </html>Nota: El código no da un error si capturo el 'ol' usando getElementbyId pero quiero saber por qué recibo un error con 'getElementByTagName'.